package com.cakeclient.clientsoap.contract;

import org.ksoap2.serialization.SoapObject;

public class Address extends ContractObject {
    public int id;
    public String ligne1;
    public String ligne2;
    public String ligne3;
    public String ligne4;
    public int postalCode;
    public String city;
    public String country;

    public Address() {
    }

    public Address(com.cakeclient.Model.Address address) {
        ligne1 = address.getLine1();
        ligne2 = address.getLine2();
        ligne3 = address.getLine3();
        ligne4 = address.getLine4();
        try {
            postalCode = Integer.parseInt(address.getPostalCode());
        } catch (Exception e) {
            //Pourquoi il faut parser le codepostal ?! Ca devrait etre un string !
        }
        city = address.getCity();
        country = address.getCountry();
    }


    @Override
    public void fill(SoapObject soapObject) {
        id = Integer.parseInt(soapObject.getPropertySafelyAsString("id"));
        ligne1 = soapObject.getPropertySafely("ligne1").toString();
        ligne2 = soapObject.getPropertySafely("ligne2").toString();
        ligne3 = soapObject.getPropertySafely("ligne3").toString();
        ligne4 = soapObject.getPropertySafely("ligne4").toString();
        try {
            postalCode = Integer.parseInt(soapObject.getPropertySafelyAsString("postalCode"));
        } catch (Exception e) {
            //Pourquoi il faut parser le codepostal ?! Ca devrait etre un string !
        }
        city = soapObject.getPropertySafely("city").toString();
        country = soapObject.getPropertySafely("country").toString();
    }
}
